import type { UnwrapNestedRefs } from 'vue'

interface ConsultTableModel {
  list: Array<any>
  total: number
}

export interface FormState {
  userRoleId: number
  userId: number
  roleId: number
}

type ConsultTableParams = Partial<Omit<ConsultTableModel, 'roleId'>>

export function getRoleInfoApi() {
  return useGet('/role/all')
}

export async function assignApi(formState: UnwrapNestedRefs<FormState> & {}) {
  return usePost(`/sUserRole/assign`, formState)
}

export function getUserRoleListApi(userId: number) {
  return useGet('/sUserRole/userRoles', { 'userId': userId })
}

export async function removeRole(formState: UnwrapNestedRefs<FormState> & {}) {
  return usePost(`/sUserRole/remove`)
}

export type{
  ConsultTableParams,
  ConsultTableModel,
}
